boxgadget: add APIs to insert gadgets next to siblings
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 24 Feb 2016 20:00:46 +0000 (12:00 -0800)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 29 Feb 2016 18:45:13 +0000 (10:45 -0800)
gtk/gtkboxgadget.c
gtk/gtkboxgadgetprivate.h

index 9f72d543b129aeeebd1630c2fd82a8b674ad0b53..2380236500fd497740d2b2b4e9207b7b652d8d47 100644 (file)
@@ -690,6 +690,40 @@ expand_func_from_flags (gboolean hexpand,
                  : (vexpand ? only_vertical : (ComputeExpandFunc) gtk_false);
 }
 
+void
+gtk_box_gadget_insert_gadget_before (GtkBoxGadget *gadget,
+                                     GtkCssGadget *sibling,
+                                     GtkCssGadget *cssgadget,
+                                     gboolean      hexpand,
+                                     gboolean      vexpand,
+                                     GtkAlign      align)
+{
+  /* Insert at the end if no sibling specified */
+  int pos = -1;
+
+  if (sibling)
+    gtk_box_gadget_find_object (gadget, G_OBJECT (sibling), &pos);
+
+  gtk_box_gadget_insert_gadget (gadget, pos, cssgadget, hexpand, vexpand, align);
+}
+
+void
+gtk_box_gadget_insert_gadget_after (GtkBoxGadget *gadget,
+                                    GtkCssGadget *sibling,
+                                    GtkCssGadget *cssgadget,
+                                    gboolean      hexpand,
+                                    gboolean      vexpand,
+                                    GtkAlign      align)
+{
+  /* Insert at the beginning if no sibling specified */
+  int pos = 0;
+
+  if (sibling && gtk_box_gadget_find_object (gadget, G_OBJECT (sibling), &pos))
+    pos++;
+
+  gtk_box_gadget_insert_gadget (gadget, pos, cssgadget, hexpand, vexpand, align);
+}
+
 void
 gtk_box_gadget_insert_gadget (GtkBoxGadget *gadget,
                               int           pos,
index 8979f70e9d7a7983a23ff5fa3b9264ff0439b826..c970a3be490d7464c0f023eee03cd839f4149939 100644 (file)
@@ -72,6 +72,19 @@ void                    gtk_box_gadget_insert_gadget            (GtkBoxGadget
                                                                  gboolean                hexpand,
                                                                  gboolean                vexpand,
                                                                  GtkAlign                align);
+void                    gtk_box_gadget_insert_gadget_before     (GtkBoxGadget           *gadget,
+                                                                 GtkCssGadget           *sibling,
+                                                                 GtkCssGadget           *cssgadget,
+                                                                 gboolean                hexpand,
+                                                                 gboolean                vexpand,
+                                                                 GtkAlign                align);
+void                    gtk_box_gadget_insert_gadget_after      (GtkBoxGadget           *gadget,
+                                                                 GtkCssGadget           *sibling,
+                                                                 GtkCssGadget           *cssgadget,
+                                                                 gboolean                hexpand,
+                                                                 gboolean                vexpand,
+                                                                 GtkAlign                align);
+
 void                    gtk_box_gadget_remove_gadget            (GtkBoxGadget           *gadget,
                                                                  GtkCssGadget           *cssgadget);
 void                    gtk_box_gadget_reverse_children         (GtkBoxGadget           *gadget);